// https://leetcode.cn/problems/maximum-depth-of-n-ary-tree/
// Created by ade on 2022/8/9.
//

/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
public:
    int maxDepth(Node* root) {
        return getHeight(root);
    }

    int getHeight(Node* root){
        if(!root) return 0;
        int maxHeight = 0;
        for(auto i : root->children){
            maxHeight = max(getHeight(i), maxHeight);
        }
        return maxHeight + 1;
    }
};